#ifndef OPENGLWRAPPER_GLRenderingContext_H_
#define OPENGLWRAPPER_GLRenderingContext_H_

#include "OpenGLPrerequisites.h"

namespace OpenGLWrapper
{
	//
	// Class that represent the rendering context of WGL for open gl, this class manage the 
	// Rendering context creation and deletion and so on
	//
	class GLRenderingContext
	{
	private:

		//
		// The Major opengl version
		//
		int _majorVersion;

		//
		// The minor opengl version
		//
		int _minorVersion;

		//
		// The Rendering context handle
		//
		HGLRC _renderingContext;

		//
		// The Device context of the window that will be used as a rendering context for openGL
		//
		HDC _hDC;	

		//
		// The display list of the font used
		//
		GLuint _fontDisplayList;

	public:

		//
		// Default constructor resposible for initializing the context and its resources
		//
		GLRenderingContext();

		//
		// Constructor that start the opengl with the specified version, if
		// it is not supported, fall back to the most one supported
		//
		GLRenderingContext(int majorVersion, int minorVersion);

		//
		// Destructor for finalizing the rendering context
		//
		~GLRenderingContext();

	public:

		//
		// Create a rendering context on the device context attached
		// Parameters : 
		//		1 - HDC hDC : the device context of the window
		//		2 - BYTE colorDepth : The color depth of the GL window
		//
		GLError CreateContext(HDC hDC, BYTE colorDepth);

		//
		// Delete the rendering context
		//
		GLError DeleteContext();

		//
		// Activate the rendering context, so that openGL operations can be done on it
		//
		GLError ActivateContext();

		//
		// De-Activate the rendering context
		//
		GLError DeActivateContext();

		//
		// Render 3D text
		//
		void RenderText(double x, double y, double z, const char* text, Color color, double size);

	public:

		//
		// Get the Device Context
		//
		HDC GetDC();

		//
		// Get the rendering context
		//
		HGLRC GetRenderingContext();

		//
		// Get the major version of open GL
		//
		int GetMajorVersion();

		//
		// Get the minor version of open GL
		//
		int GetMinorVersion();

	private:

		//
		// Setup font for opengl rendering text
		//
		void SetupFont();

		//
		// Get the max opengl version supported by the system
		//
		GLError GetMaxOpenGLVersion();

		//
		// Check for the open gl version is supported or not
		//
		GLError CheckOpenGLVersion(int majorVersion, int minorVersion);

	private:

		//
		// The Current rendering context used in the application
		//
		static GLRenderingContext* _currentRenderingContext;

	public:

		//
		// Get the current active rendering context
		//
		static GLRenderingContext* GetCurrentContext();
	};
}

#endif
